<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <span class='one'>语文</span> <span class='two'>数学</span>
    <span class='one'>化学</span> <span class='two'>英语</span>
    <script>
        //根据类名获取元素getElementsByClassName()
        var Ospan1 = document.getElementsByClassName('one');
        var Ospan2 = document.getElementsByClassName('two'); 
        Ospan1[0].style.fontWeight = 'bold';
        Ospan2[1].style.background = 'red';
    </script>
</body>
</html>